
<div class="main layui-clear">
<div class="wrap">
    <div class="content detail">
        <h1>
           <?php echo  $res[0]['title']?>
        </h1>
        <div class="fly-tip fly-detail-hint" data-id="4637">
           <?php if ($res[0]['top']!='普通'){ ?>
                <?php if ($res[0]['top']==='置顶'){ ?>
                     <span class="fly-tip-stick">置顶帖</span>
                 <?php }else if($res[0]['top']==='精华'){ ?>
                     <span class="fly-tip-jing">精帖</span>   
                    <?php }else{ ?>
                        <span class="fly-tip-stick">置顶帖</span>
                        <span class="fly-tip-jing">精帖</span> 
                       <?php } ?> 
           <?php } ?>
            <span>
                <?php echo $res[0]['status'] ?>
            </span>
            <div class="fly-list-hint">
                <i class="iconfont" title="回答">
                    &#xe60c;
                </i>
                <?php echo $res[0]["answer_num"] ?>
                <i class="iconfont" title="人气">
                    &#xe60b;
                </i>
                <?php echo $res[0]["view_num"] ?>
            </div>
        </div>
        <div class="detail-about">
            <a class="jie-user" href="/u/336/">
                <img src="__ROOT__/<?php echo $_SESSION['face'] ?>" alt="纸飞机">
                <cite>
                    <?php echo $_SESSION['nikename'] ?>
                    <em>
                        <?php echo $res[0]["create_time"] ?>
                    </em>
                </cite>
            </a>
            <div class="detail-hits" data-id="4637">
                <span style="color:#FF7200">
                    悬赏:<?php echo $res[0]["kiss"]?>飞吻
                </span>
            </div>
        </div>
        <div class="detail-body photos" style="margin-bottom: 20px;">
           <?php echo htmlspecialchars_decode($res[0]['content']) ?> 
        </div>
        <a name="comment">
        </a>
        <h2 class="page-title">
            热忱回答
            <span>
                （
                <em id="jiedaCount">
                    <?php echo $res[0]['answer_num']; ?>
                </em>
                ）
            </span>
        </h2>
        <ul class="jieda photos" id="jieda">
          <?php foreach ($ans as $v) { ?>
                <li data-id="15249">
                    <a name="item-1478067457695">
                    </a>
                    <div class="detail-about detail-about-reply">
                        <a class="jie-user" href="/u/26880/">
                            <img src="__ROOT__/<?php echo $v['face'] ?>" alt="<?php echo $v['nikename'] ?>" layer-index="0">
                            <cite>
                                <i>
                                    <?php echo $v['nikename'] ?>
                                </i>
                                <em style="color:#FF9E3F">
                                    （活雷锋）
                                </em>
                            </cite>
                        </a>
                        <div class="detail-hits">
                            <span>
                                <?php echo $v['create_time'] ?>
                            </span>
                        </div>
                    </div>
                    <div class="detail-body jieda-body">
                        <?php echo htmlspecialchars_decode($v['content']) ?>
                    </div>
                    <div class="jieda-reply">
                        <span class="jieda-zan " type="zan">
                            <i class="iconfont icon-zan">
                            </i>
                            <em class='zan' aid='<?php echo $v['id'];?>' uid='<?php echo $_SESSION["uid"];?>'><?php echo $v['zan'];?></em>
                        </span>
                        <span type="reply">
                            <i class="iconfont icon-svgmoban53">
                            </i>
                            回复
                        </span>
                    </div>
                </li>
         <?php } ?>
        </ul>
        <style type="text/css">
            .current{
                height: 37px;
                background-color: #009E94;
                color: #fff;
                padding: 0 20px;
               /* line-height: 36px;*/
                /*border: 1px solid #009E94;*/
                font-size: 14px;
                display: inline-block;
                vertical-align: top;
            }
            .num,.next,.prev{
                padding: 0 20px;
                line-height: 36px;
                border: 1px solid #009E94;
                font-size: 14px;
                display: inline-block;
                vertical-align: top;
            }
            .num{
                border-right: none;
            }
            .next{
                margin-left: -5px;
            }



        </style>    
        
            <?php if (!empty($ans)) { ?>
                <div class="laypage-main">
                <?php  echo $show; ?>
                </div>  
            <?php }else{ ?>
            <legend></legend>
                <div class="layui-field-box">
                    没有人回答，真尴尬。。
                </div>
            
              <?php  }?>
       
        <div class="layui-form layui-form-pane">
            <form action="{:U('home/que/getanswer')}" method="post">
                <div class="layui-form-item layui-form-text">
                    <div class="layui-input-block">
                        <textarea id="L_content" name="content" required lay-verify="content"
                        placeholder="我要回答" class="layui-textarea fly-editor" style="height: 150px;"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <input type="hidden" name="qid" value="<?php echo $_GET['id'] ?>">
                    <button class="layui-btn" lay-filter="add" lay-submit>
                        提交回答
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
<div class="edge">
    <h3 class="page-title">
            最近热帖
        </h3>
        <ol class="fly-list-one">
         <?php foreach ($hot as $v) { ?>
            <li>
                <a href="{:U('home/que/index')}/id/<?php echo $v['id']; ?>">
                    <?php echo $v['title']; ?>
                </a>
                <span>
                    <i class="iconfont">
                        
                    </i>
                    <?php echo $v['view_num']; ?>
                </span>
            </li>
         <?php } ?>
            
        </ol>
        
        <h3 class="page-title">
            近期热议
        </h3>
        <ol class="fly-list-one">
        <?php foreach ($hot_ans as  $v) { ?>
            <li>
                <a href="{:U('home/que/index')}/id/<?php echo $v['id']; ?>">
                     <?php echo $v['title']; ?>
                </a>
                <span>
                    <i class="iconfont"></i>
                    <?php echo $v['answer_num']; ?>
                </a>
                </span>
            </li>
        <?php }?>      
        </ol>
    
</div>
</div>

<script src="__PUBLIC__/layui/layui.js"></script>
<script src="__PUBLIC__/layui/jquery-1.7.2.js"></script>
<script type="text/javascript">
 layui.use(['form','layedit'], function(){
              var form = layui.form(),
              layer = layui.layer,
              layedit = layui.layedit;
              //建立编辑器
               edit = layedit.build('L_content', {tool: ['strong','face', 'code', 'link', 'image', '|', 'left', 'center', 'right'],
                    uploadImage:{url:"{:U('home/que/upload')}",type:""}});
                //同步编辑器的内容到texttarea
              form.verify({
                content: function(value){
                layedit.sync(edit)
                }
             });

                //监听提交
                   form.on('submit(add)', function(data){
                        $.ajax({
                             url: "{:U('home/que/getanswer')}",
                             type: 'POST',
                             dataType: 'json',
                             data: data.field,
                                success: function(data) {
                                if (data.error==0) {
                                    layer.confirm(data.info, {
                                      btn: ['确定'] //按钮
                                    }, function(){
                                       location.replace("{:U('home/login/index')}");
                                    });
                                }else if(data.error==1){
                                   layer.msg(data.info);
                                    location.href = location.href;
                                    
                                }else{
                                    layer.confirm(data.info, {
                                      btn: ['确定'] //按钮
                                    });
                                };      
                            }
                         })  
                        return false;
                    });

            });
    

    $(".icon-zan").click(function() {

        aid =  $(this).siblings('em').attr('aid');
        uid =  $(this).siblings('em').attr('uid');
        data = new Array(aid,uid);
        num =0;
        $.ajax({
            url: '{:U("home/que/zan")}',
            type: 'POST',
            dataType: 'json',
            async: false,
            data:{data: data} ,
            success: function(data) {
                if (data.error==0) {
                    layer.msg(data.info, {icon: 5});
                }else if(data.error==2){
                    num=1;
                }else{
                    num=0;
                } 
            }  
        })
        if (num==1) {
            zan=Number($(this).siblings('em').html());
            zan=zan+1;
            $(this).siblings('em').html(zan);
        }else{
            zan=Number($(this).siblings('em').html());
            zan=zan-1;
            $(this).siblings('em').html(zan);
        };
           
    });





</script>
       